/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * pronostico.java
 *
 * Created on 12-may-2011, 12:59:24
 */

package logica;

import org.scilab.forge.jlatexmath.TeXConstants;
import org.scilab.forge.jlatexmath.TeXFormula;
import org.scilab.forge.jlatexmath.TeXIcon;
import java.awt.BorderLayout;
import java.awt.Cursor;
import java.awt.image.BufferedImage;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import javax.swing.ImageIcon;
import javax.swing.JLabel;


/**
 *
 * @author joshi
 */
public class pronostico1 extends javax.swing.JFrame {

    String math = "";
    String nombre = "";
   
    public static int ymes =0, ytmes=0;
    public static int yyear =0, ytyear=0;

   

//    final public static Object datos[][] = { {"josue",1,"01,01,2010",275},
//                                {"josue",1,"03,01,2010",142},
//                                {"josue",1,"03,01,2010",142},
//                                {"josue",1, "05,01,2010", 168},
//                                {"josue",1, "15,01,2010", 197},
//                                {"josue",1, "01,02,2010", 215},
//                                {"josue",1, "03,02,2010", 188},
//                                {"josue",1, "05,03,2010", 241},
//                                {"josue",1, "16,04,2010", 295},
//                                {"josue",1, "02,05,2010", 125},
//                                {"josue",1, "10,08,2010", 266},
//                                {"josue",1, "12,09,2010", 200},
//                                {"josue",1, "12,09,2010",142},
//                                {"josue",1, "05,01,2011", 168},
//                                {"josue",1, "15,01,2011", 197},
//                                {"josue",1, "01,02,2011", 215},
//                                {"josue",1, "03,02,2011", 188},
//                                {"josue",1, "05,03,2011", 241},
//                                {"josue",1, "16,04,2011", 295},
//                                {"josue",1, "02,05,2011", 125},
//                                {"josue",1, "10,08,2011", 266},
//                                {"josue",1, "12,09,2011", 200},
//                                {"josue",1,"03,01,2012",142},
//                                {"josue",1, "05,01,2012", 168},
//                                {"josue",1, "15,01,2012", 197},
//                                {"josue",1, "01,02,2012", 215},
//                                {"josue",1, "03,02,2012", 188},
//                                {"josue",1, "05,03,2012", 241},
//                                {"josue",1, "16,04,2012", 295},
//                                {"josue",1, "02,05,2012", 125},
//                                {"josue",1, "10,08,2012", 266},
//                                {"josue",1, "12,09,2012", 200}
//                                };

    public static int mes[][]= new int[100][3];
    public static int year[][]= new int[100][2];
    public static Object datos[][]= new Object[100][4];

    public static int tamano=0;

    /** Creates new form pronostico */
    public pronostico1() {
        initComponents();
        setIconImage(new ImageIcon(getClass().getResource("/img/doncito.png")).getImage());
        setLocationRelativeTo(null);
        Leer();

        tamano();

        if(tamano>0){
        Estadisticas();
        Series();
        

        pronosticoy();
        generaserie2();

        pronosticos();
        }
        else{
             javax.swing.JOptionPane.showMessageDialog(null,"necesita mas datos para realizar un pronostivo valido");
        }

    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jSplitPane1 = new javax.swing.JSplitPane();
        jgrafico = new javax.swing.JPanel();
        jdatos = new javax.swing.JPanel();
        jpuesto = new javax.swing.JLabel();
        jseries = new javax.swing.JPanel();
        jseries1 = new javax.swing.JPanel();
        jyear = new javax.swing.JPanel();
        jmes = new javax.swing.JPanel();
        jpronostico = new javax.swing.JPanel();
        jpro1 = new javax.swing.JLabel();
        jpro2 = new javax.swing.JLabel();
        jpro3 = new javax.swing.JLabel();
        jpro = new javax.swing.JLabel();
        jpro4 = new javax.swing.JLabel();
        jpro5 = new javax.swing.JLabel();
        jpro6 = new javax.swing.JLabel();
        jpro7 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        jpro8 = new javax.swing.JLabel();
        jpro9 = new javax.swing.JLabel();
        jpro10 = new javax.swing.JLabel();
        jpro11 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jSplitPane1.setDividerLocation(350);
        jSplitPane1.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);

        javax.swing.GroupLayout jgraficoLayout = new javax.swing.GroupLayout(jgrafico);
        jgrafico.setLayout(jgraficoLayout);
        jgraficoLayout.setHorizontalGroup(
            jgraficoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 690, Short.MAX_VALUE)
        );
        jgraficoLayout.setVerticalGroup(
            jgraficoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 349, Short.MAX_VALUE)
        );

        jSplitPane1.setTopComponent(jgrafico);

        jpuesto.setText("Puesto: Ganancia:");

        javax.swing.GroupLayout jdatosLayout = new javax.swing.GroupLayout(jdatos);
        jdatos.setLayout(jdatosLayout);
        jdatosLayout.setHorizontalGroup(
            jdatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jdatosLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jpuesto, javax.swing.GroupLayout.DEFAULT_SIZE, 554, Short.MAX_VALUE)
                .addGap(126, 126, 126))
        );
        jdatosLayout.setVerticalGroup(
            jdatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jdatosLayout.createSequentialGroup()
                .addGap(51, 51, 51)
                .addComponent(jpuesto)
                .addContainerGap(57, Short.MAX_VALUE))
        );

        jSplitPane1.setRightComponent(jdatos);

        jTabbedPane1.addTab("Estadisticas", jSplitPane1);

        javax.swing.GroupLayout jseriesLayout = new javax.swing.GroupLayout(jseries);
        jseries.setLayout(jseriesLayout);
        jseriesLayout.setHorizontalGroup(
            jseriesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 692, Short.MAX_VALUE)
        );
        jseriesLayout.setVerticalGroup(
            jseriesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 478, Short.MAX_VALUE)
        );

        jTabbedPane1.addTab("Serie Ganancia", jseries);

        javax.swing.GroupLayout jseries1Layout = new javax.swing.GroupLayout(jseries1);
        jseries1.setLayout(jseries1Layout);
        jseries1Layout.setHorizontalGroup(
            jseries1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 692, Short.MAX_VALUE)
        );
        jseries1Layout.setVerticalGroup(
            jseries1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 478, Short.MAX_VALUE)
        );

        jTabbedPane1.addTab("Serie ganadores", jseries1);

        javax.swing.GroupLayout jyearLayout = new javax.swing.GroupLayout(jyear);
        jyear.setLayout(jyearLayout);
        jyearLayout.setHorizontalGroup(
            jyearLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 692, Short.MAX_VALUE)
        );
        jyearLayout.setVerticalGroup(
            jyearLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 478, Short.MAX_VALUE)
        );

        jTabbedPane1.addTab("Serie año", jyear);

        javax.swing.GroupLayout jmesLayout = new javax.swing.GroupLayout(jmes);
        jmes.setLayout(jmesLayout);
        jmesLayout.setHorizontalGroup(
            jmesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 692, Short.MAX_VALUE)
        );
        jmesLayout.setVerticalGroup(
            jmesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 478, Short.MAX_VALUE)
        );

        jTabbedPane1.addTab("Serie mes", jmes);

        jpronostico.setBackground(new java.awt.Color(255, 255, 255));

        jpro1.setText("Se necesitan más datos");

        jpro2.setText("Se necesitan más datos");

        jpro3.setText("Se necesitan más datos");

        jpro.setText("Se necesitan más datos");

        jpro4.setText("Se necesitan más datos");

        jpro5.setText("Se necesitan más datos");

        jpro6.setText("Se necesitan más datos");

        jpro7.setText("Se necesitan más datos");

        javax.swing.GroupLayout jpronosticoLayout = new javax.swing.GroupLayout(jpronostico);
        jpronostico.setLayout(jpronosticoLayout);
        jpronosticoLayout.setHorizontalGroup(
            jpronosticoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpronosticoLayout.createSequentialGroup()
                .addGap(33, 33, 33)
                .addGroup(jpronosticoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jpro4)
                    .addComponent(jpro7)
                    .addComponent(jpro6)
                    .addComponent(jpro5)
                    .addComponent(jpro)
                    .addComponent(jpro3)
                    .addComponent(jpro2)
                    .addComponent(jpro1))
                .addContainerGap(546, Short.MAX_VALUE))
        );
        jpronosticoLayout.setVerticalGroup(
            jpronosticoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpronosticoLayout.createSequentialGroup()
                .addGap(19, 19, 19)
                .addComponent(jpro)
                .addGap(18, 18, 18)
                .addComponent(jpro1)
                .addGap(18, 18, 18)
                .addComponent(jpro2)
                .addGap(18, 18, 18)
                .addComponent(jpro3)
                .addGap(49, 49, 49)
                .addComponent(jpro4)
                .addGap(18, 18, 18)
                .addComponent(jpro5)
                .addGap(18, 18, 18)
                .addComponent(jpro6)
                .addGap(18, 18, 18)
                .addComponent(jpro7)
                .addContainerGap(190, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Pronostico", jpronostico);

        jPanel2.setBackground(new java.awt.Color(255, 255, 255));

        jpro8.setText("Se necesitan más datos");

        jpro9.setText("Se necesitan más datos");

        jpro10.setText("Se necesitan más datos");

        jpro11.setText("Se necesitan más datos");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(30, 30, 30)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jpro8)
                    .addComponent(jpro11)
                    .addComponent(jpro10)
                    .addComponent(jpro9))
                .addContainerGap(549, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(24, 24, 24)
                .addComponent(jpro8)
                .addGap(18, 18, 18)
                .addComponent(jpro9)
                .addGap(18, 18, 18)
                .addComponent(jpro10)
                .addGap(18, 18, 18)
                .addComponent(jpro11)
                .addContainerGap(344, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Pronostico(2)", jPanel2);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 697, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 506, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new pronostico1().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JSplitPane jSplitPane1;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JPanel jdatos;
    private javax.swing.JPanel jgrafico;
    private javax.swing.JPanel jmes;
    private javax.swing.JLabel jpro;
    private javax.swing.JLabel jpro1;
    private javax.swing.JLabel jpro10;
    private javax.swing.JLabel jpro11;
    private javax.swing.JLabel jpro2;
    private javax.swing.JLabel jpro3;
    private javax.swing.JLabel jpro4;
    private javax.swing.JLabel jpro5;
    private javax.swing.JLabel jpro6;
    private javax.swing.JLabel jpro7;
    private javax.swing.JLabel jpro8;
    private javax.swing.JLabel jpro9;
    private javax.swing.JPanel jpronostico;
    private javax.swing.JLabel jpuesto;
    private javax.swing.JPanel jseries;
    private javax.swing.JPanel jseries1;
    private javax.swing.JPanel jyear;
    // End of variables declaration//GEN-END:variables

    private void Estadisticas() {

        String aux;


        Double total = 0.0 ;
        for (int i=0; i<tamano;i++){
            aux = datos[i][3].toString();
            total += java.lang.Double.valueOf(aux)*0.0001;
        }

        puesto pu = new puesto(total ,nombre);
        this.jgrafico.setLayout(new BorderLayout());
        this.jgrafico.setVisible(true);
        this.jgrafico.add(pu.crearpanel());

        math = "Ganancia\\ total: \t"+total;
        this.jpuesto.setIcon(get_latex(math));
    }

    private void Series() {
       // series se = new series(data,fecha);
        series se = new series("Serie de tiempo de ganancias","Fecha","Ganancias", 2, datos);
        this.jseries.setLayout(new BorderLayout());
        this.jseries.setVisible(true);
        this.jseries.add(se.createPanel());


        series se1 = new series("Serie de tiempo de ganadores","Fecha","Ganancia de Ganadores", 1, datos);
        this.jseries1.setLayout(new BorderLayout());
        this.jseries1.setVisible(true);
        this.jseries1.add(se1.createPanel());
}

     private TeXIcon get_latex(String mat){
        TeXFormula fomule = new TeXFormula(mat);
        TeXIcon ti = fomule.createTeXIcon(
        TeXConstants.STYLE_DISPLAY, 18);
        BufferedImage b = new BufferedImage(ti.getIconWidth(), ti
            .getIconHeight(), BufferedImage.TYPE_INT_RGB);
        ti.paintIcon(new JLabel(), b.getGraphics(), 0, 0);

        return ti;
    }

    private void pronosticos() {
       
       int x = tamano;
       int h=1;
       math = "Ganancias\\ por\\ dia";
       jpro.setIcon(get_latex(math));

       math = "Ganancias\\ por\\ mes";
       jpro4.setIcon(get_latex(math));

       math = "Ganancias\\ por\\ año";
       jpro8.setIcon(get_latex(math));
       
       if (x>1){

       Double dato1 =  java.lang.Double.valueOf(datos[x-1][3].toString())*0.0001;
       Double dato2 =  java.lang.Double.valueOf(datos[x-2][3].toString())*0.0001;
       Double dato4;
       Double dato3 = dato1 + (dato1-dato2);

       math = "\\hat{Y}_{t+1} = Y_{t}+(Y_{t} - Y_{t-1}) = "+ dato1 + " +("+ dato1 +" - "+dato2+") = "+dato3 + " ";
       jpro1.setIcon(get_latex(math));

       dato3=0.0;
       for(int i=tamano-1; i>0; i--){
           
             dato4 =  java.lang.Double.valueOf(datos[i][3].toString())*0.0001;
             if (i!=0){
                dato2 =  java.lang.Double.valueOf(datos[i-1][3].toString())*0.0001;
             }
             else{
                 dato2 = 0.0;
             }

             dato3 += dato4-dato2;

             if (datos[i][0]!=null){
                 h++;
             }
       }
       
       
       dato2= dato1+(dato3/h);
       math = "\\hat{Y}_{t+1} = Y_{t} + \\sum_{t=1}^{n} \\frac{(Y_{t} - Y_{t-1})}{n} = "+dato1+" "+"+\\frac{"+dato3+"}{"+h+"} = "+dato2+" " ;
       jpro2.setIcon(get_latex(math));

       dato3 = dato1*(dato1/dato2);
       math = "\\hat{Y}_{t+1} = Y_{t}\\frac{Y_{t}}{Y_{t-1}} = "+dato1 +"\\frac{"+dato1+"}{"+dato2+"} = "+dato3 + " ";
       jpro3.setIcon(get_latex(math));


       //pormes

        dato1 =  java.lang.Double.valueOf(ymes)*0.0001;
        dato2 =  java.lang.Double.valueOf(ytmes)*0.0001;
        dato3 = dato1 + (dato1-dato2);

       math = "\\hat{Y}_{t+1} = Y_{t}+(Y_{t} - Y_{t-1}) = "+ dato1 + " +("+ dato1 +" - "+dato2+") = "+dato3 + " ";
       jpro5.setIcon(get_latex(math));

       dato3=0.0;

       h=1;
       for(int i=mes.length-1; i>0; i--){

             dato4 =  java.lang.Double.valueOf(mes[i][2])*0.0001;
             if (i!=0){
                dato2 =  java.lang.Double.valueOf(mes[i-1][2])*0.0001;
             }
             else{
                 dato2 = 0.0;
             }

             dato3 += dato4-dato2;

             if (mes[i][0]!=0){
                 h++;
             }
       }

       System.out.println(dato3);
       dato2= dato1+(dato3/h);
       math = "\\hat{Y}_{t+1} = Y_{t} + \\sum_{t=1}^{n} \\frac{(Y_{t} - Y_{t-1})}{n} = "+dato1+" "+"+\\frac{"+dato3+"}{"+h+"} = "+dato2+" " ;
       jpro6.setIcon(get_latex(math));

       dato3 = dato1*(dato1/dato2);
       math = "\\hat{Y}_{t+1} = Y_{t}\\frac{Y_{t}}{Y_{t-1}} = "+dato1 +"\\frac{"+dato1+"}{"+dato2+"} = "+dato3 + " ";
       jpro7.setIcon(get_latex(math));


       //poraño

        dato1 =  java.lang.Double.valueOf(yyear)*0.0001;
        dato2 =  java.lang.Double.valueOf(ytyear)*0.0001;
        dato3 = dato1 + (dato1-dato2);

       math = "\\hat{Y}_{t+1} = Y_{t}+(Y_{t} - Y_{t-1}) = "+ dato1 + " +("+ dato1 +" - "+dato2+") = "+dato3 + " ";
       jpro9.setIcon(get_latex(math));

       dato3=0.0;

       h=1;
       for(int i=year.length-1; i>0; i--){

             dato4 =  java.lang.Double.valueOf(year[i][1])*0.0001;
             if (i!=0){
                dato2 =  java.lang.Double.valueOf(year[i-1][1])*0.0001;
             }
             else{
                 dato2 = 0.0;
             }

             dato3 += dato4-dato2;

             if (year[i][0]!=0){
                 h++;
             }
       }

       System.out.println(dato3);
       dato2= dato1+(dato3/h);
       math = "\\hat{Y}_{t+1} = Y_{t} + \\sum_{t=1}^{n} \\frac{(Y_{t} - Y_{t-1})}{n} = "+dato1+" "+"+\\frac{"+dato3+"}{"+h+"} = "+dato2+" " ;
       jpro10.setIcon(get_latex(math));

       dato3 = dato1*(dato1/dato2);
       math = "\\hat{Y}_{t+1} = Y_{t}\\frac{Y_{t}}{Y_{t-1}} = "+dato1 +"\\frac{"+dato1+"}{"+dato2+"} = "+dato3 + " ";
       jpro11.setIcon(get_latex(math));


       }





    }


    private void pronosticoy(){

        

        String vec[]= null;
        String m="", mant="";
        String y="", yant="";
        int cont = 0, conty=0;
        int sumames =0;
        int sumay=0;

        vec = datos[0][2].toString().split(",");
        mant = vec[1];
        yant = vec[2];
        

        for (int i=0; i<tamano;i++){
           vec = datos[i][2].toString().split(",");
           
           if (vec[1].compareTo(mant)==0){
               sumames += java.lang.Integer.valueOf(datos[i][3].toString());
               mes[cont][0] = java.lang.Integer.valueOf(vec[1]);
               mes[cont][1] = java.lang.Integer.valueOf(vec[2]);
               mes[cont][2] = sumames;
               mant = vec[1];
           }
           else{
               cont++;
               sumames=0;
               sumames += java.lang.Integer.valueOf(datos[i][3].toString());
               mes[cont][0] = java.lang.Integer.valueOf(vec[1]);
               mes[cont][1] = java.lang.Integer.valueOf(vec[2]);
               mes[cont][2] = sumames;
               mant= vec[1];
           }

           if (vec[2].compareTo(yant)==0){
               sumay +=java.lang.Integer.valueOf(datos[i][3].toString());
               year[conty][0] = java.lang.Integer.valueOf(vec[2]);
               year[conty][1] = sumay;
               yant = vec[2];
           }
            else{
               conty++;
               sumay=0;
               sumay += java.lang.Integer.valueOf(datos[i][3].toString());
               year[conty][0] = java.lang.Integer.valueOf(vec[2]);
               year[conty][1] = sumay;
               yant= vec[2];
           }

        }

      for (int i=0; i<mes.length; i++){
        System.out.println(mes[i][0]+" "+mes[i][1]+" "+mes[i][2]);
        
        }
            
        for (int i=0; i<mes.length; i++){
        System.out.println(year[i][0]+" "+year[i][1]);
        }
    }

    private void pronosticod(){

    }

    private void set_cursorw(){
        this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    }
    private void set_cursor(){
        this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
    }

    private void generaserie2() {
        series se = new series("Serie de tiempo de ganancias por mes","Fecha","Ganancias", 3, datos);
        this.jmes.setLayout(new BorderLayout());
        this.jmes.setVisible(true);
        this.jmes.add(se.createPanel3());


        series se1 = new series("Serie de tiempo de ganadores por año","Fecha","Ganancias", 4, datos);
        this.jyear.setLayout(new BorderLayout());
        this.jyear.setVisible(true);
        this.jyear.add(se1.createPanel4());
    }

     private void Leer() {
        File archivo = null;
      FileReader fr = null;
      BufferedReader br = null;

      try {
         // Apertura del fichero y creacion de BufferedReader para poder
         // hacer una lectura comoda (disponer del metodo readLine()).
         archivo = new File ("datos.txt");
         fr = new FileReader (archivo);
         br = new BufferedReader(fr);

         //josue,1,01,01,2010,275


         // Lectura del fichero
         String linea;
         int cont=0;
         String vec[] = null;
         while((linea=br.readLine())!=null){

            vec = linea.split(",");

            if(vec[1].compareTo("1")==0){
            datos[cont][0]=vec[0];
            datos[cont][1]=vec[1];
            datos[cont][2]=vec[2]+","+vec[3]+","+vec[4];
            datos[cont][3]=vec[5];
            cont++;
             }

          }

      }
      catch(Exception e){
         e.printStackTrace();
      }finally{
         // En el finally cerramos el fichero, para asegurarnos
         // que se cierra tanto si todo va bien como si salta
         // una excepcion.
         try{
            if( null != fr ){
               fr.close();
            }
         }catch (Exception e2){
            e2.printStackTrace();
         }
      }
    }

    private void tamano() {

        for(int i=0; i<datos.length;i++){
            if (datos[i][0]==null){
                break;
            }
            tamano++;
        }
        System.out.println(tamano);
    }


}

